package user;

import opreation.IOperation;
import opreation.impl.*;

import java.util.Scanner;

/**
 * 管理员类,可对书架进行CURD
 * @Author Stark
 * @Date 2022/1/23 17:57
 */
public class AdminUser extends User{
    private Scanner scanner = new Scanner(System.in);
    //管理员的密码
    private String password = "88888888";
    public AdminUser(String name){
        this.name = name;
        this.operations = new IOperation[]{
                //添加书籍
                new AddOperation(),
                //删除书籍
                new DeleteOperation(),
                //更新书籍
                new UpdateOperation(),
                //查询书籍
                new FindOperation(),
                //展示当前书籍列表
                new DisplayOperation()
        };
    }

    //获取密码
    public String getPassword() {
        return password;
    }

    //菜单的返回值就是用户输入的值
    @Override
    public int menu() {
        System.out.println("=======================================");
        System.out.println("欢迎管理员" + this.name + "登录比特图书管理系统");
        System.out.println("1.添加书籍");
        System.out.println("2.删除书籍");
        System.out.println("3.更新书籍");
        System.out.println("4.查询书籍");
        System.out.println("5.展示当前书籍列表");
        System.out.println("-1.退出");
        System.out.println("=======================================");
        System.out.print("请输入您的选择:");
        int choice = scanner.nextInt();
        if (choice == -1) {
            // 关闭输入
            scanner.close();
        }
        return choice;
    }
}
